***********************************************************************************************************
**************************************** NFT Collection-DMA Analysis ************************************************

clear all

*import NFT-DMA regression data 
import delimited "nft_dma_regressions.csv"


*only keep DMAs with state lottery - non-zero lottery sales
keep if no_lottery != 1 

*only keep non-zero mint price NFT collections
keep if med_mint_price > 0

*remove nft collections with over 10,000 items
keep if total_supply <= 10000

*keep only positive SVI
keep if nft_dma_svi > 0


*generate regression sample by removing NFTs with positive attention from only 1 DMA (for consistent sample size with and without NFT collection fixed effects)
eststo temp: reghdfe nft_dma_svi lot_sale_std pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)
gen nft_fe_sample = e(sample)
keep if nft_fe_sample == 1

gen total_supply_thousands = total_supply/1000

label variable nft_dma_svi "SVI"
label variable lot_sale_std "Lottery sales per capita"
label variable pop_std "Population"
label variable broadband_std "Broadband access"
label variable total_supply_thousands "Total token supply (thousands)"
label variable fees "Creator's royalty fee"
label variable advertisesrareitems "Advertises rare items (0/1)"
label variable hastwitter "Has Twitter (0/1)"
label variable hasdiscord "Has Discord (0/1)"
label variable cathprt_std "Catholic/Protestant ratio"
label variable med_income "Median income"
label variable inc_ineq "Income inequality"
label variable no_col "Non-college ratio"
label variable rural_urban "Rurality score"
label variable under_25 "Fraction < 25 years old"
label variable married "Married ratio"
label variable minority_ratio "Minority ratio"
label variable majority_male "Majority male"
label variable unemp "Unemployment rate"
label variable wallet_svi "NFT collection wallet SVI"
label variable cfpb_complaints_std "CFPB complaints (per 1000 population)"
label variable lib_vote_share "2016 election Libertarian party vote share"
label variable crypto_ads_pc_std "Advertisement spending by crypto firms ($ per 1000 population)"
label variable risk_taking_std "Regional risk-taking preferences"
label variable bubble_nft "Bubble period token"


***************************** Table 2, Panel B *********************************

*column 1
eststo r1: reghdfe nft_dma_svi lot_sale_std, noabsorb vce(cluster nft_id dma_id)

estadd local nft_fe No
estadd local nft_control No
estadd local dma_control No

*column 2
eststo r2: reghdfe nft_dma_svi lot_sale_std pop_std broadband_std, noabsorb vce(cluster nft_id dma_id)

estadd local nft_fe No
estadd local nft_control No
estadd local dma_control Yes

*column 3
eststo r3: reghdfe nft_dma_svi lot_sale_std pop_std broadband_std total_supply_thousands fees advertisesrareitems hastwitter hasdiscord, noabsorb vce(cluster nft_id dma_id)

estadd local nft_fe No
estadd local nft_control Yes
estadd local dma_control Yes

*column 4
eststo r4: reghdfe nft_dma_svi lot_sale_std pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local nft_control No
estadd local dma_control Yes

*table output
esttab r1 r2 r3 r4, replace label se drop(_cons) stats(N nft_fe nft_control dma_control r2_a, fmt(%9.0g %9.3f) labels(N "NFT collection fixed effects" "NFT collection controls" "DMA controls" "Adj. R-squared"))  starlevels( * 0.10 ** 0.05 *** 0.010)


********************************* Table 3, Column 2 ****************************


*row 1: catholic/Protestant ratio
eststo r1: reghdfe nft_dma_svi cathprt_std pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes


*row 2: median income
eststo r2: reghdfe nft_dma_svi med_income pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes


*row 3: income inequality
eststo r3: reghdfe nft_dma_svi inc_ineq pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes


*row 4: non-college ratio
eststo r4: reghdfe nft_dma_svi no_col pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes


*row 5: rurality score
eststo r5: reghdfe nft_dma_svi rural_urban pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes


*rwo 6: fraction < 25 years old 
eststo r6: reghdfe nft_dma_svi under_25 pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes


*row 7: married ratio
eststo r7: reghdfe nft_dma_svi married pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes


*row 8: minority ratio
eststo r8: reghdfe nft_dma_svi minority_ratio pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes


*row 9: majority male dummy
eststo r9: reghdfe nft_dma_svi majority_male pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes


*row 10: unemployment rate
eststo r10: reghdfe nft_dma_svi unemp pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes


*table output
esttab r1 r2 r3 r4 r5 r6 r7 r8 r9 r10, replace label se drop(_cons pop_std broadband_std) stats(N nft_fe dma_control r2_a, fmt(%9.0g %9.3f) labels(N "NFT collection fixed effects" "DMA controls" "Adj. R-squared"))  starlevels( * 0.10 ** 0.05 *** 0.010)


********************************* Table 4, Column 2 ******************************

eststo r2: reghdfe wallet_svi lot_sale_std pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes

*column output
esttab r2, replace label se drop(_cons pop_std broadband_std) stats(N nft_fe dma_control r2_a, fmt(%9.0g %9.3f) labels(N "NFT collection fixed effects" "DMA controls" "Adj. R-squared"))  starlevels( * 0.10 ** 0.05 *** 0.010)


********************************* Table 5, Panel B ******************************

*column 1
eststo r1: reghdfe nft_dma_svi lot_sale_std pop_std broadband_std cfpb_complaints_std, absorb(nft_id)  vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes


*column 2
eststo r2: reghdfe nft_dma_svi lot_sale_std pop_std broadband_std lib_vote_share, absorb(nft_id)  vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes


*column 3
eststo r3: reghdfe nft_dma_svi lot_sale_std pop_std broadband_std risk_taking_std, absorb(nft_id)  vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes

*column 4
eststo r4: reghdfe nft_dma_svi lot_sale_std pop_std broadband_std crypto_ads_pc_std, absorb(nft_id)  vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes


*table output
esttab r1 r2 r3 r4, replace label se drop(_cons pop_std broadband_std) stats(N nft_fe dma_control r2_a, fmt(%9.0g %9.3f) labels(N "NFT collection fixed effects" "DMA controls" "Adj. R-squared"))  starlevels( * 0.10 ** 0.05 *** 0.010)


********************************* Table 6, Column 4 ******************************


*column 4
eststo r4: reghdfe nft_dma_svi c.lot_sale_std##c.bubble_nft pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)
estadd local nft_fe Yes
estadd local dma_control Yes


*column output
esttab r4, replace label se drop(_cons pop_std broadband_std bubble_nft) stats(N nft_fe dma_control r2_a, fmt(%9.0g %9.3f) labels(N "NFT collection fixed effects" "DMA controls" "Adj. R-squared"))  starlevels( * 0.10 ** 0.05 *** 0.010)


***************************** Appendix: Table A.1 *************************************

*keep only DMAs with positive 14-day attention
keep if nft_dma_svi_14 > 0

*generate regression sample by removing NFTs with positive attention from only 1 DMA (for consistent sample size with and without NFT collection fixed effects)
eststo temp: reghdfe nft_dma_svi_14 lot_sale_std pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)
gen fe_sample = e(sample)
keep if fe_sample == 1


*column 1
eststo r1: reghdfe nft_dma_svi_14 lot_sale_std, noabsorb vce(cluster nft_id dma_id)

estadd local nft_fe No
estadd local dma_control No

*column 2
eststo r2: reghdfe nft_dma_svi_14 lot_sale_std pop_std broadband_std, absorb(nft_id) vce(cluster nft_id dma_id)

estadd local nft_fe Yes
estadd local dma_control Yes

*table output
esttab r1 r2, replace label se keep(lot_sale_std) stats(N nft_fe dma_control r2_a, fmt(%9.0g %9.3f) labels(N "NFT collection fixed effects" "DMA controls" "Adj. R-squared"))  starlevels( * 0.10 ** 0.05 *** 0.010)

